/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cl.orientesalud.gui.operaciones;

import cl.orientesalud.business.TratamientoDelegate;
import cl.orientesalud.dominio.Medico;
import cl.orientesalud.dominio.Paciente;
import cl.orientesalud.dominio.Tratamiento;
import cl.orientesalud.gui.OrienteSaludMainForm;
import cl.orientesalud.util.OrienteLog;
import cl.orientesalud.util.UtilForm;
import java.awt.Frame;
import java.util.Iterator;
import java.util.List;
import java.util.logging.Level;
import javax.swing.table.DefaultTableModel;
import org.apache.log4j.Logger;

/**
 *
 * @author nicolas
 */
public class BusquedaAvanzada extends javax.swing.JDialog {
    Logger logger=OrienteLog.obtenerLogger(BusquedaAvanzada.class);
    UtilForm utilForm;
    TratamientoDelegate delegate;
    Frame parent;
    /**
     * Creates new form BusquedaAvanzada
     */
    public BusquedaAvanzada(Frame parent, boolean modal) {
        super(parent, modal);
        utilForm=new UtilForm();
        delegate=new TratamientoDelegate();
        this.parent=parent;
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        panelCriterio = new javax.swing.JTabbedPane();
        panelMedico = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        txtRutMedico = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        txtNombreMedico = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        txtApPatMedico = new javax.swing.JTextField();
        btnCancelarMedico = new javax.swing.JButton();
        btnBuscarMedico = new javax.swing.JButton();
        btnLimpiarMedico = new javax.swing.JButton();
        jLabel4 = new javax.swing.JLabel();
        txtApMatMedico = new javax.swing.JTextField();
        lblMensaje = new javax.swing.JLabel();
        btnSelMed = new javax.swing.JButton();
        panelPaciente = new javax.swing.JPanel();
        jLabel6 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        txtRutPaciente = new javax.swing.JTextField();
        txtNombrePaciente = new javax.swing.JTextField();
        txtApPatPaciente = new javax.swing.JTextField();
        txtApMatPaciente = new javax.swing.JTextField();
        btnCancelarPaciente = new javax.swing.JButton();
        btnLimpiarPaciente = new javax.swing.JButton();
        btnConsultarPaciente = new javax.swing.JButton();
        btnSelPac = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        tblTratamientos = new javax.swing.JTable();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Búsqueda Avanzada");

        panelCriterio.setBorder(javax.swing.BorderFactory.createTitledBorder("Criterio de Búsqueda"));

        jLabel1.setText("Rut:");

        jLabel2.setText("Nombre:");

        txtNombreMedico.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtNombreMedicoActionPerformed(evt);
            }
        });

        jLabel3.setText("Apellido Paterno:");

        txtApPatMedico.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtApPatMedicoActionPerformed(evt);
            }
        });

        btnCancelarMedico.setText("Cancelar");
        btnCancelarMedico.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCancelarMedicoActionPerformed(evt);
            }
        });

        btnBuscarMedico.setText("Buscar");
        btnBuscarMedico.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnBuscarMedicoActionPerformed(evt);
            }
        });

        btnLimpiarMedico.setText("Limpiar");
        btnLimpiarMedico.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnLimpiarMedicoActionPerformed(evt);
            }
        });

        jLabel4.setText("Apellido Materno:");

        btnSelMed.setText("Seleccionar");
        btnSelMed.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSelMedActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout panelMedicoLayout = new javax.swing.GroupLayout(panelMedico);
        panelMedico.setLayout(panelMedicoLayout);
        panelMedicoLayout.setHorizontalGroup(
            panelMedicoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelMedicoLayout.createSequentialGroup()
                .addGroup(panelMedicoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panelMedicoLayout.createSequentialGroup()
                        .addComponent(btnCancelarMedico)
                        .addGap(3, 3, 3)
                        .addComponent(btnLimpiarMedico)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnBuscarMedico)
                        .addGap(18, 18, 18)
                        .addComponent(lblMensaje)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnSelMed))
                    .addGroup(panelMedicoLayout.createSequentialGroup()
                        .addGroup(panelMedicoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel1)
                            .addComponent(jLabel2)
                            .addComponent(jLabel3)
                            .addComponent(jLabel4))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(panelMedicoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(txtNombreMedico, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(txtRutMedico, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(txtApPatMedico)
                            .addComponent(txtApMatMedico, javax.swing.GroupLayout.DEFAULT_SIZE, 120, Short.MAX_VALUE))))
                .addGap(0, 513, Short.MAX_VALUE))
        );
        panelMedicoLayout.setVerticalGroup(
            panelMedicoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelMedicoLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelMedicoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(txtRutMedico, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panelMedicoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(txtNombreMedico, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panelMedicoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(txtApPatMedico, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panelMedicoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(txtApMatMedico, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 33, Short.MAX_VALUE)
                .addGroup(panelMedicoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnCancelarMedico)
                    .addComponent(btnBuscarMedico)
                    .addComponent(btnLimpiarMedico)
                    .addComponent(lblMensaje)
                    .addComponent(btnSelMed)))
        );

        panelCriterio.addTab("Medico", panelMedico);

        jLabel6.setText("Rut:");

        jLabel5.setText("Nombre:");

        jLabel7.setText("Apellido Paterno:");

        jLabel8.setText("Apellido Materno:");

        btnCancelarPaciente.setText("Cancelar");
        btnCancelarPaciente.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCancelarPacienteActionPerformed(evt);
            }
        });

        btnLimpiarPaciente.setText("Limpiar");
        btnLimpiarPaciente.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnLimpiarPacienteActionPerformed(evt);
            }
        });

        btnConsultarPaciente.setText("Buscar");
        btnConsultarPaciente.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnConsultarPacienteActionPerformed(evt);
            }
        });

        btnSelPac.setText("Seleccionar");
        btnSelPac.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSelPacActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout panelPacienteLayout = new javax.swing.GroupLayout(panelPaciente);
        panelPaciente.setLayout(panelPacienteLayout);
        panelPacienteLayout.setHorizontalGroup(
            panelPacienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelPacienteLayout.createSequentialGroup()
                .addGroup(panelPacienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel7)
                    .addComponent(jLabel8)
                    .addGroup(panelPacienteLayout.createSequentialGroup()
                        .addComponent(btnCancelarPaciente)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnLimpiarPaciente)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnConsultarPaciente)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnSelPac))
                    .addGroup(panelPacienteLayout.createSequentialGroup()
                        .addGroup(panelPacienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel6)
                            .addComponent(jLabel5))
                        .addGap(68, 68, 68)
                        .addGroup(panelPacienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(txtNombrePaciente, javax.swing.GroupLayout.DEFAULT_SIZE, 131, Short.MAX_VALUE)
                            .addComponent(txtApPatPaciente)
                            .addComponent(txtRutPaciente)
                            .addComponent(txtApMatPaciente, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 131, Short.MAX_VALUE))))
                .addGap(534, 534, Short.MAX_VALUE))
        );
        panelPacienteLayout.setVerticalGroup(
            panelPacienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelPacienteLayout.createSequentialGroup()
                .addGroup(panelPacienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panelPacienteLayout.createSequentialGroup()
                        .addGap(17, 17, 17)
                        .addComponent(jLabel6)
                        .addGap(10, 10, 10))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelPacienteLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(txtRutPaciente, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(panelPacienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(txtNombrePaciente, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(15, 15, 15)
                .addGroup(panelPacienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(txtApPatPaciente, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(7, 7, 7)
                .addGroup(panelPacienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtApMatPaciente, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel8))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 12, Short.MAX_VALUE)
                .addGroup(panelPacienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnCancelarPaciente)
                    .addComponent(btnLimpiarPaciente)
                    .addComponent(btnConsultarPaciente)
                    .addComponent(btnSelPac)))
        );

        panelCriterio.addTab("Paciente", panelPaciente);

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Tratamientos"));

        tblTratamientos.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Id", "Paciente", "Médico", "Fecha Inicio", "Fecha Término", "Tipo"
            }
        ));
        jScrollPane1.setViewportView(tblTratamientos);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1)
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 222, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 20, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(panelCriterio, javax.swing.GroupLayout.DEFAULT_SIZE, 857, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(panelCriterio, javax.swing.GroupLayout.PREFERRED_SIZE, 266, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void txtNombreMedicoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtNombreMedicoActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txtNombreMedicoActionPerformed

    private void txtApPatMedicoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtApPatMedicoActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txtApPatMedicoActionPerformed

    private void btnCancelarMedicoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelarMedicoActionPerformed
        this.dispose();
    }//GEN-LAST:event_btnCancelarMedicoActionPerformed

    private void btnCancelarPacienteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelarPacienteActionPerformed
        this.dispose();
    }//GEN-LAST:event_btnCancelarPacienteActionPerformed

    private void btnLimpiarMedicoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLimpiarMedicoActionPerformed
        DefaultTableModel model=(DefaultTableModel) tblTratamientos.getModel();
        utilForm.limpiarTabla(model);
        utilForm.limpiarFormulario(panelMedico);
        
        
    }//GEN-LAST:event_btnLimpiarMedicoActionPerformed

    private void btnLimpiarPacienteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLimpiarPacienteActionPerformed
        DefaultTableModel model=(DefaultTableModel) tblTratamientos.getModel();
        utilForm.limpiarTabla(model);
        utilForm.limpiarFormulario(panelPaciente);
    }//GEN-LAST:event_btnLimpiarPacienteActionPerformed

    private void btnBuscarMedicoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBuscarMedicoActionPerformed
        DefaultTableModel model=(DefaultTableModel) tblTratamientos.getModel();
        Medico medico=new Medico();
        medico.setRut(txtRutMedico.getText());
        medico.setApellidoPaterno(txtApPatMedico.getText());
        medico.setApellidoMaterno(txtApMatMedico.getText());
        medico.setNombre(txtNombreMedico.getText());
        try {
            utilForm.limpiarTabla(model);
            List<Tratamiento> tratamientos=delegate.obtenerTratamientos(medico);
            Iterator iterador=tratamientos.iterator();
            while(iterador.hasNext()){
                Tratamiento trat=(Tratamiento) iterador.next();
                model.addRow(trat.toArray());
            }
        } catch (Exception ex) {
            logger.error("Error:"+ex.getMessage());
            lblMensaje.setText(ex.getMessage());
        }
        
    }//GEN-LAST:event_btnBuscarMedicoActionPerformed

    private void btnConsultarPacienteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnConsultarPacienteActionPerformed
        DefaultTableModel model=(DefaultTableModel) tblTratamientos.getModel();
        Paciente paciente=new Paciente();
        paciente.setRut(txtRutPaciente.getText());
        paciente.setNombre(txtNombrePaciente.getText());
        paciente.setApellidoPaterno(txtApPatPaciente.getText());
        paciente.setApellidoMaterno(txtApMatPaciente.getText());
        try {
            utilForm.limpiarTabla(model);
            List<Tratamiento> tratamientos=delegate.obtenerTratamientos(paciente);
            Iterator iterador=tratamientos.iterator();
            while(iterador.hasNext()){
                Tratamiento trat=(Tratamiento) iterador.next();
                model.addRow(trat.toArray());
            }
        } catch (Exception ex) {
            logger.error("Error:"+ex.getMessage());
            lblMensaje.setText(ex.getMessage());
        }
        
    }//GEN-LAST:event_btnConsultarPacienteActionPerformed

    private void btnSelMedActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSelMedActionPerformed
        DefaultTableModel model=(DefaultTableModel) tblTratamientos.getModel();
        Integer idTratamiento=(Integer) model.getValueAt(tblTratamientos.getSelectedRow(), 0);
        ((OrienteSaludMainForm)this.parent).ingresarPagos.buscarTratamiento(String.valueOf(idTratamiento));
        this.dispose();
    }//GEN-LAST:event_btnSelMedActionPerformed

    private void btnSelPacActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSelPacActionPerformed
        DefaultTableModel model=(DefaultTableModel) tblTratamientos.getModel();
        Integer idTratamiento=(Integer) model.getValueAt(tblTratamientos.getSelectedRow(), 0);
        ((OrienteSaludMainForm)this.parent).ingresarPagos.buscarTratamiento(String.valueOf(idTratamiento));
        this.dispose();
    }//GEN-LAST:event_btnSelPacActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(BusquedaAvanzada.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(BusquedaAvanzada.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(BusquedaAvanzada.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(BusquedaAvanzada.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the dialog */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                BusquedaAvanzada dialog = new BusquedaAvanzada(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
                    @Override
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnBuscarMedico;
    private javax.swing.JButton btnCancelarMedico;
    private javax.swing.JButton btnCancelarPaciente;
    private javax.swing.JButton btnConsultarPaciente;
    private javax.swing.JButton btnLimpiarMedico;
    private javax.swing.JButton btnLimpiarPaciente;
    private javax.swing.JButton btnSelMed;
    private javax.swing.JButton btnSelPac;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JLabel lblMensaje;
    private javax.swing.JTabbedPane panelCriterio;
    private javax.swing.JPanel panelMedico;
    private javax.swing.JPanel panelPaciente;
    private javax.swing.JTable tblTratamientos;
    private javax.swing.JTextField txtApMatMedico;
    private javax.swing.JTextField txtApMatPaciente;
    private javax.swing.JTextField txtApPatMedico;
    private javax.swing.JTextField txtApPatPaciente;
    private javax.swing.JTextField txtNombreMedico;
    private javax.swing.JTextField txtNombrePaciente;
    private javax.swing.JTextField txtRutMedico;
    private javax.swing.JTextField txtRutPaciente;
    // End of variables declaration//GEN-END:variables
}
